<?php slot('studyGroupsNav', 'active')?>
<div class="messages" id="wrapper">
	<?php include_partial('global/systemMessages')?>
	<div id="content">
		<div id="main" style="padding-top: 30px;">
			<div class="main-heading">
				<h1><?php echo $message->getType() ==  'group' ? $group->getName() : render_profile_link(UserPeer::retrieveByPK($message->getTypeId())) ?></h1>
			</div>
			<?php include_partial('groups/subnav', array('group_id' => $group_id))?>
			<div class="filter-links with-icon">
				<p>
					<?php echo link_to('Write a New Message &#xBB;', 'messages/new?group_id='.$group_id)?>					
				</p>
				<ul class="messages inline">
					<li>Messages</li>
				</ul>
			</div>
				<?php include_partial('messages/subnav', array('group_id' => $group_id, 'message_id' => $message->getId(), 'active' => $message->getFolder() ))?>
				<div class="inbox-message">
					<div class="headers">
						<p class="date"><?php echo $message->getCreatedAt('%a %b %d, %Y %I:%M %p')?></p>
						<dl>
							<dt>From:</dt>
							<dd>
								<?php echo render_profile_link($message->getUserRelatedBySenderId()) ?>
							</dd>
							<dt>Subject:</dt>
							<dd><?php echo $message->getSubject() ?></dd>
						</dl>
					</div>
					<div class="message-body">
						<p><?php echo $message->getBody() ?></p>
					</div>
			<form action="<?php echo url_for('messages/create') ?>" method="post" class="leave-reply" id="messageForm">
			<?php if($message->getFolder() == MessagePeer::INBOX_FOLDER): ?>
					<fieldset>
						<div class="left-border">
							<label>Reply to this message</label>
							<textarea name="message[body]" cols="60" rows="10"></textarea>
						</div>
						<input type="image" alt="Leave a Reply" src="/images/btn_leave-reply.gif"/>
					</fieldset>
			<?php endif ?>
				<input type="hidden" name="message[subject]" value="<?php echo $message->getSubject() ?>" />
				<input type="hidden" name="group_id" value="<?php echo $group_id ?>" />
				<input type="hidden" name="folder" value="<?php echo $message->getFolder() ?>" />
				<input type="hidden" name="reply_id" value="<?php echo $message->getId() ?>" />
				<?php echo $form->renderHiddenFields() ?>
			</form>
				</div>								
		</div>
	</div>

</div>

<script type="text/javascript">

	$(document).ready(function() {
		$('#deleteMessage').click(function(){ 
			$('#messageForm').attr('action', $(this).attr('href'));	// copy over the url
			$(this).attr('href', 'javascript:void(0)');
			$('#messageForm').submit();
		});
		$('#markRead').click(function() { 
			$('#messageForm').attr('action', $(this).attr('href'));	// copy over the url
			$(this).attr('href', 'javascript:void(0)');
			$('#messageForm').submit(); 
		});
		$('#markUnread').click(function() { 
			$('#messageForm').attr('action', $(this).attr('href'));	// copy over the url
			$(this).attr('href', 'javascript:void(0)');
			$('#messageForm').submit(); 
		});
	});

	
</script>
